home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / stdlib / Mem_Bin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-22  |  1.5 KB  |  61 lines

  1. /* 
  2.  * Mem_Bin.c --
  3.  *
  4.  *    Source code for the "Mem_Bin" library procedure.  See memInt.h
  5.  *    for overall information about how the allocator works.
  6.  *
  7.  * Copyright 1985, 1988 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/Mem_Bin.c,v 1.2 88/07/25 14:19:20 ouster Exp $ SPRITE (Berkeley)";
  19. #endif not lint
  20.  
  21. #include "memInt.h"
  22.  
  23. /*
  24.  * ----------------------------------------------------------------------------
  25.  *
  26.  * Mem_Bin --
  27.  *
  28.  *    Make objects of the given size be binned.
  29.  *
  30.  * Results:
  31.  *    None.
  32.  *
  33.  * Side effects:
  34.  *    The bin corresponding to blocks of the given size is initialized.
  35.  *
  36.  * ----------------------------------------------------------------------------
  37.  */
  38. ENTRY void
  39. Mem_Bin(numBytes)
  40.     int    numBytes;
  41. {
  42.     int    index;
  43.  
  44.     LOCK_MONITOR;
  45.  
  46.     if (!memInitialized) {
  47.     MemInit();
  48.     } 
  49.     numBytes = BYTES_TO_BLOCKSIZE(numBytes);
  50.     if (numBytes > BIN_SIZE) {
  51.     UNLOCK_MONITOR;
  52.     return;
  53.     }
  54.     index = BLOCKSIZE_TO_INDEX(numBytes);
  55.     if (memFreeLists[index] == NOBIN) {
  56.     memFreeLists[index] = (Address) NULL;
  57.     }
  58.  
  59.     UNLOCK_MONITOR;
  60. }
  61.